package com.ruoyi.nongjt.service.impl;

import com.ruoyi.nongjt.mapper.PiePictureMapper;
import com.ruoyi.nongjt.service.PiePictureService;
import com.ruoyi.nongjt.domain.vo.PiePictureVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.PathVariable;

import java.util.ArrayList;
import java.util.List;

@Service
public class PiePictureServiceImpl implements PiePictureService {
    @Autowired
    private PiePictureMapper piePictureMapper;

    @Override
    public List<PiePictureVO> getPiePictureDataByYear(Integer year){
        //获取到数据库中所有的数据
        List<PiePictureVO> piePictureVOList = piePictureMapper.getPiePictureDataByYear(year);
        //创建一个空列表来储存过滤后的数据
        List<PiePictureVO> piePictureVOFilterList = new ArrayList<>();
        for(PiePictureVO piePictureVO : piePictureVOList){
            //遍历每一个数据，年份相等的就是add进滤后的列表
            if(piePictureVO.getYear() != null && piePictureVO.getYear().equals(year)){
                piePictureVOFilterList.add(piePictureVO);
            }
        }
        return piePictureVOFilterList;
    }
}
